package com.fire.commit.controller;

import com.fire.commit.domain.Report;
import com.fire.commit.service.ReportService;
import com.fire.common.controller.BaseController;
import com.fire.common.core.page.TableDataInfo;
import com.fire.common.domain.Result;
import com.fire.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/report")
@RestController
public class ReportController extends BaseController {

    @Autowired
    private ReportService reportService;

    /*
     * 条件分页查询
     * */
    @RequestMapping("/selectAllReport")
    public TableDataInfo ReportList(@RequestBody Report report) {
        startPage();
        List<Report> list = reportService.findAllReports(report);
        return getDataTable(list);
    }

    /*
     * 更新数据
     * */
    @RequestMapping("/updateReport")
    public Result updateReport(Report report) {

        Result result = reportService.updateReportStatus(report);
        return result;
    }

    /*
     * 添加数据
     * */
    @RequestMapping("/insertReport")
    public Result insertReport(Report report) {
        report.setId(IdUtils.randomUUID());
        Result result = reportService.insertReport(report);
        return result;
    }

    /*
     * 驳回
     * */
    @RequestMapping("/back")
    public Result back(Report report) {
        Result result = reportService.back(report);
        return result;
    }

    /*
     * 删除数据
     * */
    @RequestMapping("/deleteReportById")
    public Result deleteReportById(String id) {
        Result result = reportService.deleteReportById(id);
        return result;

    }


}
